package com.briup.day11.bean;

/**
 * @author ThinkBook
 */
public class School {
    private String name;
    private int num;
    //静态成员：图书馆,显示初始化
    public static String library = "栋梁图书馆";

    //添加静态代码块，对static成员进行初始化
    static {
        library = "凌志楼";
        System.out.println("static 代码块 正在执行 ...");
    }

    //新增静态方法
    public static void setLibrary(String library){
        //static方法中没有this，所以this.library是错的
        //this.library = library;   ERROR

        // static方法中不可以访问 普通数据成员
        //this.name = "中学";     ERROR

        // 如果static成员和形参名 一样，则借助 类名.static成员 区分
        School.library = library;
    }

    public School(){

    }
    public School(String name,int num){
        this.name = name;
        this.num = num;
    }
    //其他方法
    public void show(){
        System.out.println("学校名称: " + this.name);
        System.out.println("师生数量: " + num);
        System.out.println("图书馆: " + School.library);

    }
}
